//
//  Date+Exxt.swift
//  CocoProject
//
//  Created by Vill on 2023/11/3.
//

import Foundation

extension Date {
    
    // Date -> String
    func toString(_ fmt: String) -> String {
        let formatter = DateFormatter()
        formatter.dateFormat = fmt
        return formatter.string(from: self)
    }

    //格式化日期
    func formatDate(_ fmt: String) -> Date? {
        let formatter = DateFormatter()
        formatter.dateFormat = fmt
        let dateString = formatter.string(from: self)
        return formatter.date(from: dateString)
    }
}

